﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace EasyInvoice.WPF.Common
{
    public class VisibleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool visibleValue = false;
            if (value != null && value is Visibility)
            {
                visibleValue = !((Visibility)value == Visibility.Collapsed);
            }
            return visibleValue;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Visibility visibleValue = Visibility.Collapsed;
            if (value is bool)
            {
                if ((bool)value == true)
                {
                    visibleValue = Visibility.Visible;
                }
            }
            return visibleValue;
        }
    }
}
